-
Notifications
You must be signed in to change notification settings - Fork 532
feat: Add client side handlers to handle pagination + fix: Support pagination in tools change notification handler #306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
mcp/src/main/java/io/modelcontextprotocol/client/McpAsyncClient.java
Outdated
Show resolved
Hide resolved
Add client side list handlers to handle pagination for prompts, resources and resource templates.
@pantanurag555, thanks for addressing this. We already have proper pagination APIs for all server resources:
One can use The non-paginated methods ( |
That makes sense. Let me move around the implementations and make the relevant changes. |
28a678b
to
86a9579
Compare
This change enhances the client API by providing both paginated access for fine-grained control and convenience methods for retrieving complete result sets automatically. - Implement "list all" methods that automatically handle pagination using expand/reduce operations - Replace null parameters with McpSchema.FIRST_PAGE constant for better readability - Add tests for both paginated and "list all" functionality - Update method javadocs to clarify pagination behavior - Maintain backward compatibility Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Thanks @pantanurag555 ! Rebased, squashed, cleaned and merged at d4a1bfa |
Motivation and Context
Tools change notification handler is meant to send the updated list of tools to all consumers (clients) who have signed up for tools change notifications. In the current implementation in java-sdk, this would only return the first page of tools to the consumer. This PR:
How Has This Been Tested?
Wrote a unit test that broke down list tools result across pages. Tested with the code before and after the change introduced in the PR. The old code (without the PR change) fails to return the complete list of tools. The new code (with the change) successfully returns all the tools across all pages.
Breaking Changes
None
Types of changes
Checklist